<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/4/28
  Time: 19:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%--<%--%>
    <%--String username=request.getParameter("username");--%>
    <%--String password=request.getParameter("password");--%>
    <%--if (username.equals("admin")&&password.equals("123456")){--%>
        <%--//登录成功--%>
        <%--session.setAttribute("username","admin");--%>
        <%--response.sendRedirect("userList.jsp");--%>

    <%--}else {--%>
        <%--out.write("<h1>登录失败</h1>");--%>
        <%--out.write("<a href='login.jsp'>重新登录</a>");--%>
    <%--}--%>

    <%----%>
<%--%>--%>
<%
//    //得到用户的ID
//    String id = request.getParameter("id");
//    String password=request.getParameter("password");
//    //3+1
//    Connection connection=null;
//    Statement statement=null;
//    ResultSet resultSet=null;
//
//    String sql="SELECT COUNT（*）FROM user where id='"+id+"' and password='"+password+"'";
//    //查所有 是否存在
//
//    Class.forName("com.mysql.jdbc.Driver");
//    connection = DriverManager.getConnection(
//            "jdbc:mysql://localhost:3306/part_time_job?serverTimezone=UTC",
//            "root",
//            "123456"
//    );
//
//    statement = connection.createStatement();
//    resultSet=statement.executeQuery(sql);

//    int count = 0;
//
//    while(resultSet.next()){
//        count = resultSet.getInt(1);
//    }
//
//    if (count==1){
//        //登录成功
//        session.setAttribute("username",""+id+"");
//        response.sendRedirect("homePage.jsp");
//    }else {
//        out.write("<h1>登录失败</h1>");
//         out.write("<a href='login.jsp'>重新登录</a>");
//    }




//
//    if (password.equals(resultSet.equals(password))){
//        out.write("登录成功，欢迎使用");
//        session.setAttribute("id","resultSet1.equals(id)");
//        response.sendRedirect("homePage.jsp");
//    }else {
//        out.write("<h1>登录失败</h1>");
//        out.write("<a href='login.jsp'>重新登录</a>");
//    }
//
//
//
//    statement.close();
//    connection.close();
//    resultSet.close();
    String username=request.getParameter("id");
    String password=request.getParameter("password");
    if (username.equals("977798915")&&password.equals("123456")){
        //登录成功
        session.setAttribute("username","lyj");
        response.sendRedirect("homePage.jsp");

    }else {
        out.write("<h1>登录失败</h1>");
        out.write("<a href='login.jsp'>重新登录</a>");
    }

%>

</body>
</html>
